#!/bin/bash

set -e

case "$1" in
   configure)
      ln --force --symbolic /opt/pi4j/bin/pi4j /usr/bin/pi4j
   ;;
   abort-upgrade|abort-remove|abort-deconfigure)
      echo "$1"
    ;;
   *)
      echo "postinst called with unknown argument \`\$1'" >&2
      exit 0
   ;;
esac

# SET EXECUTABLE PERMISSIONS FOR EXAMPLE BUILD SCRIPTS
chmod -f -R a+x /opt/pi4j/examples/build
chmod -f -R a+x /opt/pi4j/examples/bananapi/build
chmod -f -R a+x /opt/pi4j/examples/bananapro/build
chmod -f -R a+x /opt/pi4j/examples/odroid/c1/build
chmod -f -R a+x /opt/pi4j/examples/odroid/xu4/build

# SET EXECUTABLE PERMISSIONS FOR EXAMPLE RUN SCRIPTS
chmod -f -R a+x /opt/pi4j/examples/run
chmod -f -R a+x /opt/pi4j/examples/bananapi/run
chmod -f -R a+x /opt/pi4j/examples/bananapro/run
chmod -f -R a+x /opt/pi4j/examples/odroid/c1/run
chmod -f -R a+x /opt/pi4j/examples/odroid/xu4/run
